package com.woniuxy.controller;

import com.woniuxy.entity.Books;
import com.woniuxy.mapper.BooksMapper;
import com.woniuxy.service.BooksService;
import com.woniuxy.util.MinioUtils;
import com.woniuxy.util.PageParam;
import com.woniuxy.util.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.awt.print.Book;

/**
 * @author HP
 * @version 1.0
 * @project
 * @description
 * @date 2024/4/9 10:48:36
 */
@RestController
@RequestMapping("book")
public class BookController {

    @Autowired
    private MinioUtils minioUtils;

    @Autowired
    private BooksService booksService;

    @Autowired
    private BooksMapper booksMapper;



    @PostMapping("upload")
    public ResponseData<?> uploadBookImage(MultipartFile file) throws Exception {
        return minioUtils.uploadFile(file, "image");
    }

    @PostMapping("queryBooks")
    public ResponseData<?> queryBooks(@RequestBody PageParam<Books> pageParam){
        return booksService.queryBooks(pageParam);
    }

    @PostMapping("addBooks")
    public ResponseData<?> addBooks(@RequestBody Books books){
        return booksService.addBooks(books);
    }
}
